MAKETOOL_DIR = $(ARMHOME)\Bin
WORKROOT_DIR = .\..\..\mtk
PROJECT_PATH = $(WORKROOT_DIR)\project
OBJFILE_PATH = $(PROJECT_PATH)\arm7
SOURCE_PATH = $(WORKROOT_DIR)\source
WRAPPER_PATH = $(WORKROOT_DIR)\..\..\..\platform
PART3D_ZIP_PATH = $(WORKROOT_DIR)\..\..\..\part3d\zip\source
API_SOURCE_PATH = $(WORKROOT_DIR)\..\..\..\platform\mtk\mw_api\src 

VER_GEN_TOOL = C:\progra~1\TortoiseSVN\bin\subwcrev.exe

#DEC_LIB = $(WORKROOT_DIR)\..\..\..\miicodec\bin\mt6225\miidec.lib
#ENC_LIB = $(WORKROOT_DIR)\..\..\..\miicodec\bin\mt6225\miienc.lib

!IF "$(RELEASE_FLAG)" == "release"
RELEASE_PATH = $(WORKROOT_DIR)\mtk6253_09A\lib\release
OPTION_DEFS = 
AM_LIBS = $(WORKROOT_DIR)\..\..\AppManager\lib\release\AppManager_arm7.lib
MW_LIBS = $(WORKROOT_DIR)\..\..\middleware\lib\release\middleware_arm7.lib
BILL_LIBS = $(WORKROOT_DIR)\..\..\..\imeworks\lib\release\bill_trigger_arm7.lib
!ELSE
RELEASE_PATH = $(WORKROOT_DIR)\mtk6253_09A\lib\debug
OPTION_DEFS = -DIMITV_DEBUG_VERSION -DIMITV_SCREEN_ROTATION
AM_LIBS = $(WORKROOT_DIR)\..\..\AppManager\lib\debug\AppManager_arm7.lib
MW_LIBS = $(WORKROOT_DIR)\..\..\middleware\lib\debug\middleware_arm7.lib
BILL_LIBS = $(WORKROOT_DIR)\..\..\..\imeworks\lib\debug\bill_trigger_arm7.lib
!ENDIF

COMPILE_FLAG = -cpu ARM7EJ-S -littleend -O2 -zo -fa -Ec $(OPTION_DEFS)
ASAMBLE_FLAG = -cpu ARM7EJ-S -littleend

RELEASE_LIBS = $(RELEASE_PATH)\imibase_arm7.lib

COMPLIER_CCC = "$(MAKETOOL_DIR)\tcc.exe" #armcc.exe thumb/arm
COMPILER_CPP = "$(MAKETOOL_DIR)\tcpp.exe" #armcpp.exe thumb/arm
ASAMBLER_ASM = "$(MAKETOOL_DIR)\armasm.exe"
ARCHIVE_TOOL = "$(MAKETOOL_DIR)\armar.exe"
EXELINK_TOOL = "$(MAKETOOL_DIR)\armlink.exe"
FROMELF_TOOL = "$(MAKETOOL_DIR)\fromelf.exe"
			
WRAPPER_OBJS = $(OBJFILE_PATH)\imp_io_wrapper.obj \
				$(OBJFILE_PATH)\imp_os_wrapper.obj \
				$(OBJFILE_PATH)\imp_pictext_wrapper.obj \
				$(OBJFILE_PATH)\imp_png_wrapper.obj \
				$(OBJFILE_PATH)\imp_sock_wrapper.obj \
				$(OBJFILE_PATH)\imp_syspara_wrapper.obj \
				$(OBJFILE_PATH)\imp_vui_wrapper.obj \
				$(OBJFILE_PATH)\imp_mm_wrapper.obj \
				$(OBJFILE_PATH)\imp_mw_wrapper.obj \
				$(OBJFILE_PATH)\imp_vpp_wrapper.obj \
				$(OBJFILE_PATH)\imp_bill_wrapper.obj \
				$(OBJFILE_PATH)\imp_jpegdec_wrapper.obj \
				$(OBJFILE_PATH)\imp_timer_wrapper.obj
				
PART3D_ZIP_OBJS = $(OBJFILE_PATH)\mb_zip_pal.obj \
					$(OBJFILE_PATH)\mb_unzip.obj 

SOURCE_OBJS = $(OBJFILE_PATH)\imibase.obj

AM_LIBRARY : WRAPPER_OBJS SOURCE_OBJS PART3D_ZIP_OBJS VER_GEN
	$(ARCHIVE_TOOL) -r imibase_temp.lib $(WRAPPER_OBJS) $(SOURCE_OBJS) $(PART3D_ZIP_OBJS) $(AM_LIBS) $(MW_LIBS) $(BILL_LIBS)
	copy imibase_temp.lib $(RELEASE_LIBS)
	del imibase_temp.lib

WRAPPER_OBJS :
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_io_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_io_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_os_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_os_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_pictext_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_pictext_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_png_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_png_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_sock_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_sock_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_syspara_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_syspara_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_timer_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_timer_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_mm_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_mm_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_vui_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_vui_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_vpp_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_vpp_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_mw_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_mw_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_bill_wrapper.obj -c $(WRAPPER_PATH)\imi_mw\imp_bill_wrapper.cpp
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imp_jpegdec_wrapper.obj -c $(WRAPPER_PATH)\mtk\imp_jpegdec_wrapper.cpp

PART3D_ZIP_OBJS :
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\mb_zip_pal.obj -c $(PART3D_ZIP_PATH)\mb_zip_pal.c
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\mb_unzip.obj -c $(PART3D_ZIP_PATH)\mb_unzip.cpp
	
SOURCE_OBJS:	
	$(COMPILER_CPP) $(COMPILE_FLAG) -o $(OBJFILE_PATH)\imibase.obj -c $(SOURCE_PATH)\imibase.cpp

VER_GEN :
 -$(VER_GEN_TOOL) $(PROJECT_PATH) $(WORKROOT_DIR)\source\template.h $(WORKROOT_DIR)\source\imibase_verno.h